<?php

include '../app/common.php';
include '../check.php';

?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <title>表单页面</title>
    <link href="../component/pear/css/pear.css" rel="stylesheet">
</head>
<body class="pear-container">
<div class="layui-row layui-col-space10">
    <div class="layui-col-md12">

        <div class="layui-card">
            <div class="layui-tab layui-tab-brief" lay-filter="TabBrief">
                <ul class="layui-tab-title">
                    <li class="layui-this">邮箱设置</li>
                </ul>


                <div class="layui-tab-content">
                    <!--邮箱设置-->
                    <div class="layui-tab-item layui-show">
                        <form class="layui-form edit-form" action="" lay-filter="component-form-element">
                            <div class="layui-form-item">
                                <label class="layui-form-label">
                                    邮箱账号
                                </label>
                                <div class="layui-input-block">
                                    <input autocomplete="off" class="layui-input" name="mail_name" value="<?php echo $config['mail_name']?>" type="text"/>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">
                                    邮箱授权码
                                </label>
                                <div class="layui-input-block">
                                    <input autocomplete="off" class="layui-input"  name="mail_pwd" value="<?php echo $config['mail_pwd']?>" type="text"/>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">
                                    邮箱端口
                                </label>
                                <div class="layui-input-block">
                                    <input autocomplete="off" class="layui-input"  name="mail_port" value="<?php echo $config['mail_port']?>" type="text"/>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">
                                    邮箱服务器
                                </label>
                                <div class="layui-input-block">
                                    <input autocomplete="off" class="layui-input"  name="mail_smtp" value="<?php echo $config['mail_smtp']?>" type="text"/>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-input-block">
<!--                                    <pre style="color: #00a65a">保存后,再进行测试发信</pre>
-->                                    <button type="submit" class="pear-btn pear-btn-normal pear-btn-primary" lay-submit="" lay-filter="configform">保存设置</button>
<!--                                    <button type="submit" class="pear-btn pear-btn-normal pear-btn-success" lay-submit="" lay-filter="testSendEmail">测试发信</button>
-->                                </div>

                            </div>
                        </form>
                    </div>


            </div>
        </div>

    </div>
</div>
<script src="../component/layui/layui.js"></script>
<script src="../component/pear/pear.js"></script>
<script>
    layui.use(['form','element','code'], function() {
        var form = layui.form;
        var element = layui.element;
        let $ = layui.jquery;

        layui.code();


        form.on('submit(configform)', function(data) {
            let loading = layer.load();
            $.ajax({
                url:  "ajax.class.php?act=saveEmailSet",
                data:JSON.stringify(data.field),
                dataType:'json',
                contentType:'application/json',
                type:'post',
                success:function(result){
                    layer.close(loading);
                    if (result.code == 1) {
                        layer.msg(result.msg, {
                            icon: 1,
                            time: 1000
                        }, function() {

                        });
                    } else {
                        layer.msg(result.msg, {
                            icon: 2,
                            time: 1000
                        });
                    }
                }
            })
            return false;
        });

    });
</script>
</body>
</html>
